package com.gsoe.auth.controller;

import com.gsoe.auth.dto.GetMessageDTO;
import com.gsoe.auth.dto.SendMessageDTO;
import com.gsoe.auth.vo.MessageVO;
import com.gsoe.auth.service.MessageService;
import com.gsoe.base.model.Result;
import jakarta.validation.Valid;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 * 班级消息表 前端控制器
 * </p>
 *
 * @author xiaoma
 * @since 2024-12-14
 */
@RestController
@RequestMapping("/message")
public class MessageController {
    @Autowired
    private MessageService messageService;



    @PostMapping("/sendMessage")
    public Result<String> sendMessage(@RequestBody @Valid SendMessageDTO sendMessageDTO) {
        messageService.sendMessage(sendMessageDTO);
        return Result.success("ok");
    }

    @PostMapping("/getMessage")
    public Result<List<MessageVO>> getMessage(@RequestBody @Valid GetMessageDTO getMessageDTO) {
        return Result.success(messageService.getMessage(getMessageDTO));
    }
}
